package com.dxiang.demo.service;

import com.alibaba.fastjson.JSONObject;
import com.dxiang.demo.mapper.CommonValueMapper;
import com.dxiang.demo.model.CommonValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommonValueService {

    private final Logger log = LoggerFactory.getLogger(CommonValueService.class);

    @Autowired
    private CommonValueMapper valueMapper;

    /**
     * 获取所有的通用信息
     * @return
     * @throws Exception
     */
    public JSONObject getCommonValue() throws Exception{
        JSONObject jsonObject = new JSONObject();
        List<CommonValue> commonValues = valueMapper.getCommonValue();
        jsonObject.put("commonType",commonValues);
        return jsonObject;
    }


    /**
     * 根据id来获取所有的通用信息
     * @param parentId
     * @return
     * @throws Exception
     */
    public List<CommonValue> getCommonValueByParentId(String parentId) throws  Exception{
        return valueMapper.getCommonValueByParentId(parentId);
    }
}
